//轮播效果
var srcs = ["../images/1.jpg", "../images/2.jpg", "../images/3.jpg", "../images/4.jpg"]
var j = 0;
var dsq;
function autoMove() {
    j++
    if (j > 3) {
        j = 0
    }
    $(".navimg").append($(`<img class='lb' src='${srcs[j]}'>`));
    $(".lb:eq(0)").remove();
    $(`.index:eq(${j})`).addClass("bg").siblings().removeClass('bg');
}
dsq = setInterval(autoMove, 4000)
$(".qh").mouseenter(e => {
    clearInterval(dsq)
    if (e.target.nodeName == "LI") {
        j = $(e.target).index();
        $(".navimg").append($(`<img class='lb' src='${srcs[j]}'>`));
        $(".lb:eq(0)").remove();
        $(`.index:eq(${j})`).addClass("bg").siblings().removeClass('bg');
    }
})
$(".qh").mouseleave(() => {
    dsq = setInterval(autoMove, 4000)
})

//下拉框
$(".fenlei").mouseenter(() => {
    $(".top-submenu").css("display", "block")
})
$(".top-submenu").mouseleave(() => {
    $(".top-submenu").css("display", "none")
})


$(".ul_s").click(e => {
    console.log(e.target)
    if (e.target.nodeName == 'SPAN') {
        sessionStorage.id = $(e.target).parent().parent().parent().parent().attr("id")
        console.log(sessionStorage.id)
    } else if (e.target.nodeName == 'A') {
        sessionStorage.id = $(e.target).parent().attr("id")
        console.log(sessionStorage.id)
    } else if (e.target.nodeName == 'P') {
        sessionStorage.id = $(e.target).parent().parent().parent().attr("id")
        console.log(sessionStorage.id)
    } else if (e.target.nodeName == 'IMG') {
        sessionStorage.id = $(e.target).parent().parent().attr("id")
        console.log(sessionStorage.id)
    }
    location = 'xiangqing.html'
})

if (sessionStorage.name) {
    var u1 = sessionStorage.name;
    $.ajax({
        "url": "../php/index.php",
        "data": `user=${u1}`,
        "dataType": "JSON",
        "success": data => {
            sessionStorage.total=data.length;
            $(".tol").html(`${sessionStorage.total}`);
        }
    })
}

